﻿$(function () {
    ReplaningPhotos();
    $(window).resize(function () { ReplaningPhotos(); });
});

function ReplaningPhotos() {
    $('ul.gallery-map li.cleanrow').remove();
    var rowCount = 0;
    var toppos = $('ul.gallery-map li a:eq(0)').position().top;
    $('ul.gallery-map li a').each(function () {
        if ($(this).position().top != toppos) return false;
        rowCount++;
    });
    $('ul.gallery-map li:nth-child(4n)').each(function () {
        $(this).after('<li class="cleanrow cleaner" />')
    });
}